class Car(val Licensenumber:String, val brand:String,val color:String,val price:Double) {
  def drive(d:Double):Unit={
    println("您已开了 $x 公里. ")
  }
  def stop():Unit={
    println("停车.")
  }
  def add():Unit={
    println("添加汽油。")
  }
}

class ElectricCar(Licensenumber: String, brand: String, color: String, price: Double, val battery: Double, var distance: Double) extends Car(Licensenumber, brand, color, price) {
  def recharge(): Unit = {
    println("充电")
  }

  override def drive(x: Double): Unit = {
    if (distance >= x) {
      distance -= x
      println(s"已行驶 $x 公里.")
    } else {
      println("电量不足.")
    }
  }
}